var categoryLevel1=null
var categoryLevel2=null;
var categoryLevel3=null;
var path = $("#path").val();


$(function (){
    categoryLevel1=$("#categoryLevel1")
    categoryLevel2=$("#categoryLevel2")
    categoryLevel3=$("#categoryLevel3")
    //初始化的时候，要把所有的提示信息变为：* 以提示必填项，更灵活，不要写在页面上
    categoryLevel2.next().html(" ");
    categoryLevel3.next().html(" ");
    /*$.ajax({
        type:"GET",
        url:path+"/appcategory/Xiala",
        data:{id:categoryLevel1.val()},
        dataType:"json",
        success:function (data){
            if (data!=null){
                var str = "<option value=''> " + "请选择" + "</option>;";
                for (var i=0; i<data.length;i++){
                    str+="<option value=\""+data[i].id+"\">"+data[i].categoryName+"</option>";
                }
                categoryLevel2.html(str);
            }
        }
    });*/
 categoryLevel1.click(function(){
     $.ajax({
         type:"GET",
         url:"/AppManage/appcategory/Xiala",
         data:{id:categoryLevel1.val()},
         dataType:"json",
         success:function (data){
             if (data!=null){
                 var str = "<option value=''> " + "请选择" + "</option>;";
                 for (var i=0; i<data.length;i++){
                     str+="<option value=\""+data[i].id+"\">"+data[i].categoryName+"</option>";
                 }
                 categoryLevel2.html(str);
             }
         }
     });
 })
   /* categoryLevel2.bind("blur",function (){
        $.ajax({
            type:"GET",
            url:"/AppManage/appcategory/Xiala",
            data:{id:categoryLevel2.val()},
            dataType:"json",
            success:function (data){
                if (data!=null){
                    var str = "<option value=''> " + "请选择" + "</option>;";
                    for (var i=0; i<data.length;i++){
                        str+="<option value=\""+data[i].id+"\">"+data[i].categoryName+"</option>";
                    }
                    categoryLevel3.html(str);
                }
            }
        });
    })*/
    categoryLevel2.click(function (){
        $.ajax({
            type:"GET",
            url:"/AppManage/appcategory/Xiala",
            data:{id:categoryLevel2.val()},
            dataType:"json",
            success:function (data){
                if (data!=null){
                    var str = "<option value=''> " + "请选择" + "</option>;";
                    for (var i=0; i<data.length;i++){
                        str+="<option value=\""+data[i].id+"\">"+data[i].categoryName+"</option>";
                    }
                    categoryLevel3.html(str);
                }
            }
        });
    })
})